﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using FRL.DebtChased.Website;

namespace WebApplication.Finance
{

	/// <summary>
	/// Declaration of FinanceMaster class
	/// </summary>
	public partial class FinanceMaster : System.Web.UI.MasterPage
	{

		/////////////////////////////////////////////////////////////
		// Attributes

		private MySession m_mySession = null;

		public bool m_bShowError = false;
		public string ErrorMessage
		{
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					this.lbErrors.Text = null;
					m_bShowError = false;
				}
				else
				{
					this.lbErrors.Text = value;
					m_bShowError = true;
				}
			}
		}

		/////////////////////////////////////////////////////////////
		// Event handlers

		protected void Page_Load(object sender, EventArgs e)
		{

            // If this is a postback...
			if (this.IsPostBack)
			{


			}
			else
			{

				// Inform the session of the page that is being loaded
				if (m_mySession == null)
					m_mySession = MySession.BindMySession();
				m_mySession.LoadingPage(this.Page.AppRelativeVirtualPath);

				// Set panel colours
				MyApplication myApp = MyApplication.BindMyApplication();
				pnlLogoBox.BackColor = myApp.PrimaryWebColor;

				// Set menu colors
				finMainMenu.ForeColor = myApp.PrimaryWebColor;
				finMainMenu.DynamicHoverStyle.ForeColor = myApp.SecondaryWebColor;
				finMainMenu.DynamicHoverStyle.BackColor = System.Drawing.Color.White;
				finMainMenu.DynamicMenuStyle.BackColor = myApp.PrimaryWebColor;
				finMainMenu.DynamicMenuItemStyle.ForeColor = System.Drawing.Color.White;
				finMainMenu.StaticHoverStyle.ForeColor = myApp.SecondaryWebColor;

				// Set menu colors - border colours
				finMainMenu.StaticSelectedStyle.BorderColor = myApp.SecondaryWebColor;
				finMainMenu.DynamicSelectedStyle.BorderColor = myApp.SecondaryWebColor;

			}

		}

		protected void FinMainMenu_MenuItemDataBound(object sender, MenuEventArgs e)
		{
#if DEBUG
			if(m_mySession==null)
				return;
#endif // #if DEBUG

		}

		protected void butDevMessage_Click(object sender, EventArgs e)
		{

			// Compose a url
			string strUrl = string.Format("~/Finance/DevMessage.aspx?url={0}",
				Path.GetFileName(this.Page.AppRelativeVirtualPath)
			);
			Response.Redirect(strUrl);

		}

	}

}